from django.contrib.auth import authenticate, login, logout
from django.shortcuts import redirect
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def sjglogin(request):
    password = request.POST.get('password')
    username = request.POST.get('username')
    user = authenticate(username =username, password = password)
    print(user)
    if user is not None:
        print("login it")
        login(request,user)
        return redirect('/')
    else:
        return redirect('/static/login.html')

def sjglogout(request):
    logout(request)
    return redirect("/static/login.html")